<?php

/**
 * Class ApiController
 */
class ArticleController extends BaseController
{

	/*
	|--------------------------------------------------------------------------
	| API控制器
	|--------------------------------------------------------------------------
	|   GetStorageDetail                仓储详情
	|   GetHarbourDetail                港口详情
	|   GetForestDetail                 林场详情
	|
	*/
    /** 文章列表  **/
    public function ShowArticleList()
    {
        $info = ArticleService::instance()->ShowArticleList();
        return $this->view('admin.show_article')->with('articles',$info);
    }

    /** 新增文章 **/
    public function AddArticle()
    {
        if(Request::isMethod('POST'))
        {
            #收集信息
            $aData = new stdClass();
            $aData->article_title            =     $this->getParam('article_title');
            $aData->author                   =     $this->getParam('author');
            $aData->keywords                 =     $this->getParam('keywords');
            $aData->cate_id                  =     $this->getParam('cate_id');
            $aData->thumb_img                =     $this->getParam('thumb_img');
            $aData->brief                    =     strip_tags($this->getParam('brief'));
            $aData->content                  =     strip_tags($this->getParam('content'));
            #逻辑操作
            ArticleService::instance()->AddArticle($aData);
            return Redirect::to('/show_article');}else{
            $cate = OtherService::instance()->ShowHelpList();
            return $this->view('admin.add_article')->with('cate',$cate);
        }
    }



}
